package com.pengcheng.taskapplication.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;


import com.pengcheng.taskapplication.R;
import com.pengcheng.taskapplication.model.SubscribeOrderListModel;
import com.pengcheng.taskapplication.model.TaskVo;
import com.pengcheng.taskapplication.mvp.view.widget.CircleImageView;

import java.util.List;

public class LisenceAdapter extends BaseAdapter {

	Context context;
	LayoutInflater inflater;
	List<SubscribeOrderListModel> subscribeOrderListModels;
	int last_item;
	private int selectedPosition = -1;
	public LisenceAdapter(Context context, List<SubscribeOrderListModel> subscribeOrderListModels){
		this.context = context;
		this.subscribeOrderListModels = subscribeOrderListModels;
		inflater= LayoutInflater.from(context);
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return subscribeOrderListModels.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return subscribeOrderListModels.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		ViewHolder  holder = null;
		if(convertView==null){
			convertView = inflater.inflate(R.layout.activity_e_lisence_list_item_layout, null);
			holder = new ViewHolder();
			holder.tv_plate =(TextView)convertView.findViewById(R.id.tv_plate);
			holder.tv_code=(TextView)convertView.findViewById(R.id.tv_code);
			holder.tv_time=(TextView)convertView.findViewById(R.id.tv_time);
			holder.tv_status=(TextView)convertView.findViewById(R.id.tv_status);
			convertView.setTag(holder);
		}
		else{
			holder=(ViewHolder)convertView.getTag();
		}

		SubscribeOrderListModel model= subscribeOrderListModels.get(position);
		holder.tv_plate.setText(model.getPlateNo());
		holder.tv_code.setText(model.getCode());
		holder.tv_time.setText(model.getSubscribeDt());
		if(model.getProgressCode()==0) {
			holder.tv_status.setText("申请中");
		}else if(model.getProgressCode()==-1000){
			holder.tv_status.setText("申请退回");
		}else if(model.getProgressCode()==1000){
			holder.tv_status.setText("已完成");
		}
		return convertView;
	}

	public static class ViewHolder{
		public TextView tv_plate;
		public TextView tv_code;
		public TextView tv_time;
		public TextView tv_status;

	}

	public void setSelectedPosition(int position) {
		selectedPosition = position;
	}

}
